<!-- colum right -->
<div class="middle myclear">
	<div class="pad10">
    <table width="100%" class="marbottom10 martop20"  border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="50%">
				<p class="title text-666">
					<?php echo $banner_lang['SearchBanner']?>
				</p>
			</td>
			<td width="50%" class="ver-middle">
				<p class="float-right">
					<a class="btn" href="<?php echo site_url('home/createAd')?>">
						<span><?php echo $banner_lang['creatAd']?></span>
					</a>
				</p>
			</td>
		</tr>
	</table>
    <div id="campaigndiv">
		<table class="tbl-list" width="100%" cellpadding="0" cellspacing="0" border="1" id="table">
        <thead>
			<tr>
				<th class="td-label bold text-center ver-middle" width="25">
					<span><?php echo $banner_lang['#'];?></span>
				</th>
				
				<th class="td-label bold text-center ver-middle" width="50">
					<span><?php echo $banner_lang['preview'];?></span>				</th>
				
				<th class="td-label bold text-center ver-middle" width="155">
                    <p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $banner_lang['ad'];?></p>
				</th>
				
				<th class="td-label bold text-center ver-middle" width="43">
					<span><?php echo $banner_lang['status'];?></span>
				</th>
				
				<th class="td-label bold text-center ver-middle {sorter: 'fancyNumber'}" width="49">
					<p class="ver-middle" style="height:33px;line-height: 33px;">Click</p>
				</th>
				
				<th class="td-label bold text-center ver-middle {sorter: 'fancyNumber'}" width="76">
					<p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $banner_lang['impressions'];?></p>
				</th>
				
				<th class="td-label bold text-center ver-middle {sorter: 'fancyNumber'}" width="85">
					<p class="ver-middle" style="height:33px;line-height: 33px;"><?php echo $banner_lang['uv'];?></p>
				</th>
				
				<th class="td-label bold text-center ver-middle" width="55">
					<p class="ver-middle" style="height:33px;line-height: 33px;">CRT %</p>
				</th>
			</tr>
        </thead>
        <tbody>
			<?php $index=1+($page-1)*$numrow;
            foreach($info as $if)
            {
            ?>
			<tr>
				<td class="ver-middle">
					<p class="mar5 text-center">
						<?php echo $index;?>
					</p>
				</td>
				
				<td class="ver-middle">
					<p class="db-list-cl-img">
                        <a>
					        <img alt="" src="<?php echo $if['filepath'];?>" width="40" height="40"/>
                        </a>
					</p>
				</td>
				
				<td class="ver-middle">
					<div class="db-list-cl-banner">
						<p >
                            <a href="<?php echo site_url('bannerdetail/index?bannerid='.$if['bannerid'].'&fromdate='.$fromdate1.'&todate='.$todate)?>">
							   <?php echo $if['bannername'];?>
                            </a>
						</p>
						<p class="text-999">
                            <a href="<?php echo site_url('campaigndetail/index?campaignid='.$if['campaignid'].'&fromdate='.$fromdate1.'&todate='.$todate)?>">
							   <?php echo $if['campaignname'];?>
                            </a>
						</p>
					</div>
				</td>
				
				<td class="ver-middle">
					<p class="text-center">
                        <?php //echo $if['status'];
                        if($if['outofstore']==1)
                            echo '<img class="cursor-pointer" alt="" src="/images/dealed.png" title="'.$banner_lang['dealed'].'"/>';
                        elseif($if['status']==-1)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgok.gif" title="'.$banner_lang['completed'].'"/>';
                        elseif($if['status']==0)
                            echo '<img class="cursor-pointer" alt="" src="/images/temp_deleted.gif" title="'.$banner_lang['temp_deleted'].'"/>';
                        elseif($if['status']==1)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgrun.gif" title="'.$banner_lang['running'].'"/>';
                        elseif($if['status']==2)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgpause.gif" title="'.$banner_lang['paused'].'"/>';
                        elseif($if['status']==3)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgwait.png" title="'.$banner_lang['waiting'].'"/>';
                        elseif($if['status']==4)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgproblem.png" title="'.$if['error'].'"/>';
                        elseif($if['status']==5)
                            echo '<img class="cursor-pointer" alt="" src="/images/imgout-of-money.png" title="'.$banner_lang['outofmoney'].'"/>';
                        elseif($if['status']==6)
                            echo '<img class="cursor-pointer" alt="" src="/images/het_ngan_sach.gif" title="'.$banner_lang['het_ngan_sach'].'"/>';
                        elseif($if['status']==8)
                            echo '<img class="cursor-pointer" alt="" src="/images/chochay.gif" title="'.$banner_lang['waittorun'].'"/>';
                        else
                            echo $if['status'];
                        ?>
					</p>
				</td>
				<td class="ver-middle">
					<div class="db-list-cl-click">
						<p>
							<?php echo $if['clicks']=='N/A' ? 'N/A':number_format($if['clicks']);?>
						</p>
					</div>
				</td>
				
				<td class="ver-middle">
					<div class="db-list-cl-imp">
						<p>
							<?php echo $if['impressions']=='N/A' ? 'N/A':number_format($if['impressions']);?>
						</p>
						<p class="myclear padtop5">
							<!--<img class="block" alt="" src="images/arrowdown.gif" />-->
						</p>
					</div>
				</td>
				
				<td class="ver-middle">
					<div class="db-list-cl-uv">
						<p>
							<?php echo $if['uviews']=='N/A' ? 'N/A':number_format($if['uviews']);?>
						</p>
						<p class="myclear padtop5">
							<!--<img class="block" alt="" src="images/arrowdown.gif" />-->
						</p>
					</div>
				</td>
				
				<td class="ver-middle">
					<div class="db-list-cl-ctr">
						<p>
							<?php echo $if['CTR'];?>
						</p>
						<p class="myclear padtop5">
							<!--<img class="block" alt="" src="images/arrowdown.gif" />-->
						</p>
					</div>
                    <input type="hidden" class="abcdef" value="<?php echo $if['bannerid']; ?>" />
				</td>
			</tr>
			<?php
            $index++;
            }
            ?>
        </tbody>
		</table>
        <div id="pager" style="font-family: tahoma;border: solid 1px #D6D6D6;float: right; margin-top: 10px;background-color: white;padding:3px 10px 4px;">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td class="ver-middle">
                        <span class="ver-middle"><?php echo $banner_lang['page'];?></span>
                        <input readonly="readonly" type="text" id="pagedisplay" class="pagedisplay ver-middle" size="2" style="border:0;" value="<?php echo $page.'/'.$totalpage;?>"/>
                    </td>
                    <td class="ver-middle" style="padding-bottom: 2px;">
                        <img src="/images/imgpre.gif" class="prev ver-middle" id="prev" <?php echo ($page>1)? 'onclick="prev_page();"':'';?>/>
                        <img src="/images/imgnext.gif" class="next ver-middle" id="next" <?php echo ($page<$totalpage)? 'onclick="next_page();"':'';?>/>
                    </td>
                    <td style="padding-top: 2px;">
                        <select class="pagesize ver-middle" style="border: 0;background: #fff;" id="pagesize" onchange="pagesize1()">
                			<option value="10" <?php echo ($numrow==10) ? 'selected="selected"':'' ;?>>10</option>
                			<option value="20" <?php echo ($numrow==20) ? 'selected="selected"':'' ;?>>20</option>
                			<option value="30" <?php echo ($numrow==30) ? 'selected="selected"':'' ;?>>30</option>
                			<option value="40" <?php echo ($numrow==40) ? 'selected="selected"':'' ;?>>40</option>
                		</select>
                    </td>
                </tr>
            </table>       
        </div>
	<br /><br /><br /><br /><br />
	<p class="text-right pad10">
		<img id="top" class="cursor-pointer" alt="" src="/images/backtotop.gif" onclick="window.scrollTo(0,0); return false;"/>
	</p>
	
</div> <!-- end colum right -->		
		<!-- important. fix for ie 6. Don't remove -->
		<!--[if IE 6]><br class="clearboth" /><![endif]-->
</div> <!-- end page content -->
</div>
<script type="text/javascript">
    var myBannerDetailTextExtraction = function(node)
    {  
    	var cellIndex = node.cellIndex;
    	var rel = '';
    	switch(cellIndex)
    	{
    		case 4:
                var arrA = $(node).find('a');
                
                if(arrA.length > 0)
                {
                   rel = $.trim($(arrA[0]).html());
    		  	   rel = rel.replace(/,/g,'');
	               rel = (rel == 'N/A') ? '-1' : rel;
                }
                else
                {
                    rel = $.trim($(node).find('p').html());
        			rel = rel.replace(/,/g,'');
        			rel = (rel == 'N/A') ? '-1' : rel;
                } 
    			break;
    		case 5:
    			var arrA = $(node).find('a');
                
                if(arrA.length > 0)
                {
                   rel = $.trim($(arrA[0]).html());
    		  	   rel = rel.replace(/,/g,'');
	               rel = (rel == 'N/A') ? '-1' : rel;
                }
                else
                {
                    rel = $.trim($(node).find('p').html());
        			rel = rel.replace(/,/g,'');
        			rel = (rel == 'N/A') ? '-1' : rel;
                } 
    			break;
    		case 6:
    			var arrA = $(node).find('a');
                
                if(arrA.length > 0)
                {
                   rel = $.trim($(arrA[0]).html());
    		  	   rel = rel.replace(/,/g,'');
	               rel = (rel == 'N/A') ? '-1' : rel;
                }
                else
                {
                    rel = $.trim($(node).find('p').html());
        			rel = rel.replace(/,/g,'');
        			rel = (rel == 'N/A') ? '-1' : rel;
                } 
    			break;
    		case 7:
    			var arrA = $(node).find('a');
                
                if(arrA.length > 0)
                {
                   rel = $.trim($(arrA[0]).html());
    		  	   rel = rel.replace(/,/g,'');
	               rel = (rel == 'N/A') ? '-1' : rel;
                }
                else
                {
                    rel = $.trim($(node).find('p').html());
        			rel = rel.replace(/,/g,'');
        			rel = (rel == 'N/A') ? '-1' : rel;
                } 
    			break;
    	}
    	return rel;
    };

    jQuery.tablesorter.addParser({
          id: "fancyNumber",
          is: function(s) {
            return /^[0-9]?[0-9,\.]*$/.test(s);
          },
          format: function(s) {
            return jQuery.tablesorter.formatFloat( s.replace(/,/g,'') );
          },
          type: "numeric"
        });
    $('#table').tablesorter({textExtraction: myBannerDetailTextExtraction});
    
    $(function()
    {
        $("#top")
            .mouseover(function() 
            { 
                document.getElementById("top").src = "/images/top.gif";
            })
            .mouseout(function() 
            {
                document.getElementById("top").src = "/images/backtotop.gif";
            });
    });
    
    function next_page()
    {
        var page = <?php echo $page?>+1; 
        var numrow = $('#pagesize').val();
        url = '<?php echo site_url('banner/search');?>?page='+page+'&numrow='+numrow+'&name=<?php echo $name?>';
        window.location = url;
    }
    
    function prev_page()
    {
        var page = <?php echo $page?>-1; 
        var numrow = $('#pagesize').val();
        url = '<?php echo site_url('banner/search');?>?page='+page+'&numrow='+numrow+'&name=<?php echo $name?>';
        window.location = url;
    }
    
    function pagesize1(numrow)
    {
        var numrow = $('#pagesize').val();
        url = '<?php echo site_url('banner/search');?>?page=1&numrow='+numrow+'&name=<?php echo $name?>';
        window.location = url;
    }
</script>